<template>
   	<div class="container" v-title data-title='申诉'>
		<Header title="申诉"></Header>
		<textarea class="followTextarea" placeholder="请填写申诉内容" v-model="remark"></textarea>
		<div class="operation-btn">
			<button class="btn btn-line btn-primary" @click="btnSubmit" v-show="btnShow">提交</button>
			<button class="btn btn-line btn-cancel" @click="btnCancel">取消</button>
		</div>
    </div>
</template>
<script>
	export default{
		data(){
			return {
				id: this.$route.params.id,
				remark: '',
				btnShow: true
			}
		},
		components: {
		},
		mounted:function(){
		},
		methods:{
			btnCancel(){
				var id=this.$route.params.id;
				this.$router.push({name: 'declareDetail',params:{id:id}})
			},
			btnSubmit(){
			    //若为游客则弹出绑定对话框
				this.tourist();

				var _self = this;
				var flag = true;
				if(!_self.remark){
					flag = false;
					layer.msg("请填写申诉内容",{
						time: 2000
					});
				}
				if(_self.remark.length > 200){
					flag = false;
					layer.msg("申诉内容不能超过200字符",{
						time: 2000
					});
				}
				if(flag){
					_self.btnShow = false;
					var params = {};
					params.cusPremisesId = _self.id;
					params.staffId = window.sessionStorage.getItem(_self.utilHelper.appAgency+"_userId");
					params.remark = _self.remark;
					var body = {};
					body.params = params;
					var url = this.utilHelper.apiUrl+'/api/addAppeal';
					this.$http.post(url, body).then((response)=>{
						var body = response.body;
						if(body.result == 1){
							layer.msg("提交成功",{
								time: 2000
							}, function(){
								_self.btnShow = true;
								_self.$router.push({name: 'declareDetail',params:{id:params.cusPremisesId}})
							});
						}else{
							_self.btnShow = true;
							layer.msg(body.resData.resultMsg, {
								time: 2000
							});
						}
					});
				}
			}
		}
	}
	
</script>